package com.wujing.high

/**
 * Apply 关键子
 */
object ApplyDemo {
  def main(args: Array[String]): Unit = {
    val value = List(1, 2, 3)

    val pig = new Pig("huahhua")

    //使用apply
    val pig1 = Pig("baibai")
    val pig2 = Pig()


    println(pig1.name)
    println(pig2.name)
  }

}
class Pig(pName:String){
  var name:String=pName
}

object Pig{
  def apply(pName: String): Pig = new Pig(pName)
  def apply():Pig=new Pig("匿名")
}
